<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Safe #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Module      :  Text.Parsec.String</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Copyright   :  (c) Antoine Latter 2011</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/parsec/LICENSE)</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Maintainer  :  aslatter@gmail.com</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Convenience definitions for working with lazy 'Text.Text'.</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Text.Parsec.Text.Lazy</span><span>
</span><span id="line-18"></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Text.Parsec.Text.Lazy.html#Parser"><span class="hs-identifier">Parser</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Text.Lazy.html#GenParser"><span class="hs-identifier">GenParser</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Text.Parsec.Text.Lazy.html#parseFromFile"><span class="hs-identifier">parseFromFile</span></a></span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../text/src/Data.Text.Lazy.html#"><span class="hs-identifier">Data.Text.Lazy</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Text</span></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html"><span class="hs-identifier">Text.Parsec.Prim</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Text.Parsec.Error.html"><span class="hs-identifier">Text.Parsec.Error</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../text/src/Data.Text.Lazy.IO.html#"><span class="hs-identifier">Data.Text.Lazy.IO</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">TL</span></span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">type</span><span> </span><span id="Parser"><span class="annot"><a href="Text.Parsec.Text.Lazy.html#Parser"><span class="hs-identifier hs-var">Parser</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="../../text/src/Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text.Text</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">type</span><span> </span><span id="GenParser"><span class="annot"><a href="Text.Parsec.Text.Lazy.html#GenParser"><span class="hs-identifier hs-var">GenParser</span></a></span></span><span> </span><span id="local-6989586621679061345"><span class="annot"><a href="#local-6989586621679061345"><span class="hs-identifier hs-type">st</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Text.Parsec.Prim.html#Parsec"><span class="hs-identifier hs-type">Parsec</span></a></span><span> </span><span class="annot"><a href="../../text/src/Data.Text.Internal.Lazy.html#Text"><span class="hs-identifier hs-type">Text.Text</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061345"><span class="hs-identifier hs-type">st</span></a></span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-comment">-- | @parseFromFile p filePath@ runs a strict text parser @p@ on the</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- input read from @filePath@ using 'Data.Text.Lazy.IO.readFile'. Returns either a 'ParseError'</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- ('Left') or a value of type @a@ ('Right').</span><span>
</span><span id="line-32"></span><span class="hs-comment">--</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- &gt;  main    = do{ result &lt;- parseFromFile numbers &quot;digits.txt&quot;</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- &gt;              ; case result of</span><span>
</span><span id="line-35"></span><span class="hs-comment">-- &gt;                  Left err  -&gt; print err</span><span>
</span><span id="line-36"></span><span class="hs-comment">-- &gt;                  Right xs  -&gt; print (sum xs)</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- &gt;              }</span><span>
</span><span id="line-38"></span><span class="hs-comment">--</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- @since 3.1.14.0</span><span>
</span><span id="line-40"></span><span>
</span><span id="line-41"></span><span id="local-6989586621679061363"><span class="annot"><a href="Text.Parsec.Text.Lazy.html#parseFromFile"><span class="hs-identifier hs-type">parseFromFile</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Text.Parsec.Text.Lazy.html#Parser"><span class="hs-identifier hs-type">Parser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061363"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="Text.Parsec.Error.html#ParseError"><span class="hs-identifier hs-type">ParseError</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679061363"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-42"></span><span id="parseFromFile"><span class="annot"><span class="annottext">parseFromFile :: forall a. Parser a -&gt; FilePath -&gt; IO (Either ParseError a)
</span><a href="Text.Parsec.Text.Lazy.html#parseFromFile"><span class="hs-identifier hs-var hs-var">parseFromFile</span></a></span></span><span> </span><span id="local-6989586621679061337"><span class="annot"><span class="annottext">Parser a
</span><a href="#local-6989586621679061337"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679061336"><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679061336"><span class="hs-identifier hs-var">fname</span></a></span></span><span>
</span><span id="line-43"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679061335"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679061335"><span class="hs-identifier hs-var">input</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FilePath -&gt; IO Text
</span><a href="../../text/src/Data.Text.Lazy.IO.html#readFile"><span class="hs-identifier hs-var">TL.readFile</span></a></span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679061336"><span class="hs-identifier hs-var">fname</span></a></span><span>
</span><span id="line-44"></span><span>         </span><span class="annot"><span class="annottext">Either ParseError a -&gt; IO (Either ParseError a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Parser a -&gt; () -&gt; FilePath -&gt; Text -&gt; Either ParseError a
forall s t u a.
Stream s Identity t =&gt;
Parsec s u a -&gt; u -&gt; FilePath -&gt; s -&gt; Either ParseError a
</span><a href="Text.Parsec.Prim.html#runP"><span class="hs-identifier hs-var">runP</span></a></span><span> </span><span class="annot"><span class="annottext">Parser a
</span><a href="#local-6989586621679061337"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">FilePath
</span><a href="#local-6989586621679061336"><span class="hs-identifier hs-var">fname</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679061335"><span class="hs-identifier hs-var">input</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-45"></span></pre></body></html>